<?php

namespace app\admin\controller;

use app\common\AdminController;
use app\admin\model\Toollabel as ToollabelDB;
class Toollabel extends AdminController
{
  protected $field = [];
  protected $allowField = ['label_name', 'label_val'];
  protected function initialize()
  {
    $this->model = new ToollabelDB();
  }

  public function list(array $rule = [], array $field = [], array $association = [], array $hidden = [])
  {
    $rule = [
      "labelName" => [
        "mode" => "like",
        "field" => "label_name",
      ],
      "labelVal" => [
        "mode" => "like",
        "field" => "label_val",
      ],
      "createTime" => [
        "mode" => "between",
        "field" => "create_time",
      ],
    ];
    
    // $list = $this->model->select()->toArray();
    return parent::list($rule, $this->field);
  }

  public function add(array $allowField = [], array $association = [], $data = [], $returnId = true)
  {
    $allowField = $this->allowField;
    $allowField[] = 'create_time';
    $allowField[] = 'create_by';
    return parent::add($allowField);
    ;
  }

  public function update(array $allowField = [], array $where = [], array $association = [], $data = [])
  {
    $allowField = $this->allowField;
    $allowField[] = 'update_time';
    $allowField[] = 'update_by';
    return parent::update($allowField);
  }

  public function del($ids, $type = false, $where = [])
  {
    return parent::del($ids);
  }

  public function get($id, array $field = [], array $where = [], array $association = [], array $hidden = [])
  {
    return parent::get($id, $this->field);
  }
}
